Posting a textarea

Since I’ve seen a couple of mentions lately of the problems associated with posting a <textarea> in a Blogger post, I thought I’d post my solution: write the <textarea> in javascript.

The problem: when you try to edit a post which contains a <textarea>, and thus also a </textarea>, the <textarea> in the Blogger interface where you edit your post is prematurely closed by the </textarea> in your post, causing you to lose everything after that in your post. Ouch.

The solution: rather than posting the <textarea> directly, write it with javascript:


<script type="text/javascript">
document.write("<" + "textarea rows='25' cols='50'><" + "/textarea>")
</script>
<noscript>Javascript required. Sorry.</noscript>

4 Comments

Comment by ruzz #
2002-04-27 16:03:43

funny. I noticed the same problem with BigBlogTool recently with the growing popularity of tag board.

I think I’m going to implement stripping the text area out (or converting to special chars) when saving and editing but putting it back in for publishing.

I’m going to have to play with it a bit.. but it would save people needing to do the above anyways..

 
Comment by Phil Ringnalda #
2002-04-27 16:33:20

Yeah, it’s been a while since I played with it from the perspective of a tool maker rather than a tool user, but it seems to me that if your load-for-editing routine just passes the post through a regexp that looks for </textarea> and replaces it with &lt;/textarea&gt;, then it looks normal to the user, but doesn’t abnormally truncate the post.

I can’t believe I’m crazy enough to post that here, though, since I know damn well my comment admin script is going to self-destruct on this thread if I ever edit it.

 
Comment by ruzz #
2002-04-28 13:15:11

precisely what i was planning on doing. Its on the list now..

 
Comment by bgdg #
2002-11-27 07:33:01

gngn

 

Sorry, the comment form is closed at this time.